package com.liu.fresh.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.liu.fresh.biz.IOrderInfoBiz;
import com.liu.fresh.entity.OrderInfo;

@Controller
@RequestMapping("/orderInfo")
public class OrderInfoController  {
	@Autowired
	private IOrderInfoBiz orderInfoBiz;
	
	@RequestMapping("/addOrderInfo")
	@ResponseBody
	public Integer addOrderInfo(String ono, String odate, String ano, String price) {
		Integer in = 0;
		try {
			in = orderInfoBiz.addOrderInfo(ono, odate,ano,price);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return in;
	}
	
	@RequestMapping("/getOrder")
	@ResponseBody
	public List<OrderInfo> getOrder(String mno) {
		return orderInfoBiz.getOrder(mno);
	}
	
	@RequestMapping("/getallOrder")
	@ResponseBody
	public List<OrderInfo> getallOrder(String mno) {
		return orderInfoBiz.getallOrder(mno);
	}
	
	@RequestMapping("/setStatus")
	@ResponseBody
	public Integer setStatus(String ono) {
		System.out.println("修改1");
		return orderInfoBiz.setStatus(ono);
	}
	
	@RequestMapping("/getOrderByPage")
	@ResponseBody
	public List<OrderInfo> getOrderByPage(String mno, Integer page) {
		return orderInfoBiz.getOrderByPage(mno,page);
	}
	
	@RequestMapping("/getPage")
	@ResponseBody
	public Integer getPage(String mno) {
		int total=orderInfoBiz.getTotal(mno);
		int page=total%2==0?total/2:total/2+1;
		return page;
	}
}
